import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    redirect: "/login",
  },
  {
    path: '/login',
    component: () => import( '../views/LoginView.vue'),
  },
  {
    path: '/lockwindow',
    component: () => import( '../views/LockWindowsView.vue'),
  },
  {
    path: '/home',
    component: () => import('../views/HomeView.vue'),
    children: [
      // {
      //   path: '',
      //   redirect: "shouye"
      // },
      {
        path: 'shouye',
        component: () => import('../components/ShouyeComponent.vue'),
      },
      {
        path: 'xitong',
        component: () => import( '../components/XitongYonghu.vue'),
      },
      {
        path: 'wz',
        component: () => import( '../components/wenzhang/Wenzhangbiao.vue'),
      },
      {
        path: 'wzfenlei',
        component: () => import( '../components/wenzhang/Wzfenleibiao.vue'),
      },
      {
        path: 'zixunshi',
        component: () => import( '../components/zixunshi/Zixunshibiao.vue'),
      },

      {
        path: 'shanchang',
        component: () => import( '../components/Shanchanglingyu.vue'),
      },
      {
        path: 'kcb',
        component: () => import( '../components/kechengbiao/Kechengbiao.vue'),
      },
      {
        path: 'kcfenlei',
        component: () => import( '../components/kechengbiao/KCfenleibiao.vue'),
      },
      {
        path: 'kcpingjia',
        component: () => import( '../components/kechengbiao/KCpingjiabiao.vue'),
      },
      {
        path: 'Fee',
        component: () => import( '../components/Fee.vue'),
      },

      {
        path: 'zxgonggao',
        component: () => import( '../components/Zixungonggao.vue'),
      },
      {
        path: 'xlceping',
        component: () => import( '../components/Xinliceping.vue'),
      },
      {
        path: 'zxyuyue',
        component: () => import( '../components/Zixunyuyue.vue'),
      },
      {
        path: 'user',
        component: () => import( '../user/User.vue'),
      },
      {
        path: 'audiofm',
        component: () => import('../components/AudioFM.vue')
      },
      {
        path: 'zhishi',
        component: () => import('../components/XinLiZhiShi.vue')
      },
      {
        path: 'gongyizhongxin',
        component: () => import('../components/Gongyizhongxin.vue')
      },
      {
        path: 'zixunhuifu',
        component: () => import( '../components/zixunhuifuComponent.vue')
      },
      {
        path: 'yonghupingjia',
        component: () => import( '../components/yonghupingjiaComponent.vue')
      },
      {
        path: 'wenti',
        component: () => import( '../components/wentiComponent.vue')
      },
      {
        path: 'huifu',
        component: () => import( '../components/huifuComponent.vue')
      },
      {
        path: 'chat',
        component: () => import('../components/ChatComponent.vue'),
        beforeEnter: (to, from, next) => {
          const userInfo = sessionStorage.getItem('user')
          if (!userInfo) {
            next('/login')
          } else {
            next()
          }
        }
      }







    ],

  },




]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
